#include <iostream>
#include "GpuParser.h"
#include "GpuDimension.h"
#include "QuerySpecification.h"


int main()
{
	//////////////////////////////////////
	// parse the XML file			

	QuerySpecification spec;	
	
	//spec.update("sample XML - all possible settings.xml");
	spec.update("/media/hd1/baozhifeng/abc/sample-output.xml");
	// we can incrementally update the spec by calling the update function multiple times
	// e.g.
	// spec.update('spec1.xml');
	// spec.update('spec2.xml');

	std::cout<<spec.appType<<std::endl;
	std::cout<<spec.searchPhase<<std::endl;
	std::cout<<spec.invertedListPath<<std::endl;
	std::cout<<spec.invertedIndexLengthFile<<std::endl;
	std::cout<<spec.searchMethod<<std::endl;
	std::cout<<spec.numOfDocToExpand<<std::endl;
	std::cout<<spec.totalDimension<<std::endl;	
	std::cout<<spec.topK<<std::endl;	

	for (int i=0; i<spec.minDomainForAllDimension.size(); i++){
		std::cout<<spec.minDomainForAllDimension.at(i)<<' ';
	}
	std::cout<<std::endl;
	for (int i=0; i<spec.maxDomainForAllDimension.size(); i++){
		std::cout<<spec.maxDomainForAllDimension.at(i)<<' ';
	}
	std::cout<<std::endl;	


	// get the query set
	std::vector<GpuQuery> querySet = spec.querySet;

	// output the query set

	for (int i=0; i<querySet.size(); i++)
	{
		std::cout<<querySet.at(i).queryID<<std::endl;
		
		for (int j=0; j<querySet.at(i).keywords.size(); j++){
			std::cout<<querySet.at(i).keywords.at(j)<<' ';
		}
		std::cout<<std::endl;

		std::cout<<querySet.at(i).upwardSearchBound<<std::endl;
		std::cout<<querySet.at(i).downwardSearchBound<<std::endl;
		std::cout<<querySet.at(i).numOfDimensionToSearch<<std::endl;
		std::cout<<querySet.at(i).aggregateFunction<<std::endl;
		for (int j=0; j<querySet.at(i).numOfDimension; j++)
		{
			std::cout<<querySet.at(i).dimensionSet.at(j).dimension<<std::endl;
			std::cout<<querySet.at(i).dimensionSet.at(j).weight<<std::endl;
			std::cout<<querySet.at(i).dimensionSet.at(j).distanceFunctionPerDimension<<std::endl;
		}
	}
	

	// we call call your interface, like
	// init_new_query(spec.querySet, spec.querySetSize);
	
	//getchar();
	return 0;
}



